home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
By Popular Request 2.0
/
By Popular Request 2.0 (Arsenal Computer).ISO
/
amiga_3
/
headtl11.ads
< prev
next >
Wrap
Text File
|
1995-07-23
|
5KB
|
145 lines
Short: Show first/last n lines/chars of a file.
Author: D. Chapman/Dan Cannon <dan@blender.demon.co.uk>
Uploader: Dan Cannon <dan@blender.demon.co.uk>
Type: util/cli
This is an update to headtail.lha, written by D. Chapman. It was going wrong
sometimes, I changed it to work with longer lines. While I was at it, I made
it so that the file name can be case insensitive (eg. you can call it head,
Head, tail, TAIL, etc...) because it checks its own file name to work out
whether you want head or tail.
Anyway, copy HeadTail to C:Head and C:Tail and you're sorted.
Dan.
----- Original Read Me -----
Short: unix-style head/tail, better than others
Well, yes, they are, to be honest. I haven't yet seen a "head" or
"tail" program for AmigaDOS which even implemented the lbc stuff in
the "real" tail for Unix. Though numerous, all the tails I've seen
can only do lines, with one exception that could do chars. This last,
however, couldn't read from standard input. I found my work severely
limited; I maintain that head and tail are among the most useful tools
in the unix environment.
So here's a tail program that reads any number of files, or standard
input; if more than one file is read, the start of each file is noted
in stderr, with files sections themselves going to stdout. Unlike
most other Amiga tails I've seen, headtail can do head-relative or
tail-relative tailing by using "+" or "-" before the count. E.g., for
the file:
Start
Line1
Line2
Line4
End
> tail +3l <file>
would report:
Line2
Line4
End
while
> tail -3l <file>
would report:
Line4
End
You see?
Character units (specifiec with "c" in place of "l") work similarly;
> tail -7 <file>
on the above example file would return:
e4
End
(You must remember to count line feeds.)
Blocks work the same way; a block is equivalent to 512 characters.
You can change this in the source code to 488 if you use an OFS
system; it will more accurately reflect your actual file structure.
AND, AS AN ADDED BONUS:
The Unix "head" is included, too. Soaring above even Unix head,
however, headtail's head will take all the same arguments as tail.
The only difference in meaning is that "+" and "-" swap places; i.e,
Program Sign Meaning
tail + count is relative to start of file
tail - count is relative to end of file
head + count is relative to end of file
head - count is relative to start of file
Thus Unix-formatted commands work with headtail, but there are more
option if you want them.
BUT WAIT -- THERE'S EVEN MORE!
As a special for Kickstart v36+ users, head and tail are included as
one program. It works like compress: there's one program, and its
function is determined by its name. Basic installation consists of
copying tail to somewhere in your path, and making a link from "head"
to "tail". (You could, of course, do it the other way.) If called as
"head", the program performs head stuff; if called as "tail", it does
tail stuff. If called something else, it still does tail stuff.
If you don't have 2.0, you should. But you can still use headtail by
just copying the program to "head", then to "tail". They don't have
to be links, but it saves disk space if they are.
HeadTail was written by David Champion some time in July - August
1992. It was compiled with Matt Dillon's DICE, and the source code is
geared toward that compiler. SAS users will have to perform surgery
to make it work, I know. I tried and gave up becasue I hate SAS
anyway. Aztec users might have to do cosmetic stuff. GCC works fine;
just be sure you've either #defined of -D-defined GCC.
This stuff, binary and source, is public domain. I release all
liability for damages brought about by usage at just the wrong time of
day in La Paz, or whatever else could cause a problem, along with
rights to the code. It's everyone's now.
------------------------------------------------------------
Amiga Distribution System
------------------------------------------------------------
ADS Zone: 1
ADS Hatch Site: Don Plesky
ADS Position: ADS Zone 1 Coordinator
BBS Name: EastPointe Amiga BBS
Phone Number(s): 810-773-6959
Network Address: 1:120/229
Network Region: 11
BBS Hours: 24 Hrs/Day
BBS Mailer/Software: DLG Trapdoor/PDQmail
BBS Storage Space: 2 Gig
File Requestable : <X> Y < > N
File Request Hours : All The Time
---------------------------------------------------------------
Help the Amiga! Join the ADS team Become a ADS Hub<=>Freq ADSINFO
---------------------------------------------------------------